
import pygame.mouse
from pygame.locals import *

from cores.core import *
from cores.dynamics import *
from cores.ui import *

from cores.graphictools import Drawer

Game.init()

###

demops = RigidSquarePS()
for i in range(5):
    sb = SquareBody(demops, Square((200 + i * 100, 300), 100))

###
testsq = Square(Vector2(500), 100)


#####
m = Mouse()

pausing = False

while not pygame.event.peek(QUIT):
    Camera.screen.fill("black")
    delta = Game.clock.tick(60)

    testsq.rotate_ip(0.04)
    testsq.draw()

    demops.update(delta)
    if not pausing:

        for i, sp in enumerate(demops.sprites()):
            sp.given_impulse((pygame.mouse.get_pos() - sp.square.center).normalize() * 4)
            Drawer.ray(sp.square.center, sp.rotation)


    m.update(delta)


    for event in pygame.event.get():
        if event.type == QUIT:
            Game.quit()

        elif event.type == MOUSEBUTTONDOWN:
            pausing = not pausing
    pygame.display.flip()

pygame.quit()
sys.exit()
